//
//  FMNavgationItem.m
//  app001
//
//  Created by founder on 14-6-22.
//  Copyright (c) 2014年 HeYang. All rights reserved.
//

#import "FMNavgationItem.h"
#define WR_IOS7_OR_LATER   ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )
#define kRightNegativeSpacerLeft WR_IOS7_OR_LATER ? -15.f : 0.f

@implementation FMNavgationItem

- (void)dealloc {
    [self setBackButton:nil];
    
}

-(id)init {
    self = [super init];
    if( self ) {
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _backButton.frame = CGRectMake(0, 0, 34, 44);
        
    }
    return self;
}

- (NSArray*)getNavgationItemWithType:(WRNavgationType)type Ima:(UIImage*)ima ImaHighlight:(UIImage*)imaHL title:(NSString*)title {
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:_backButton];
    //2013.9.30  修复ios7 navigationBar 左右barButtonItem 留有空隙bug
    //2013-12-26 
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    negativeSpacer.width = kRightNegativeSpacerLeft;
    
    [_backButton setImage:ima forState:UIControlStateNormal];
    [_backButton setImage:imaHL forState:UIControlStateHighlighted];
    [_backButton setTitle:title forState:UIControlStateNormal];
    if (type!=WRNavgationTypeCenter) {
        return [NSArray arrayWithObjects:negativeSpacer,leftItem, nil];
    }
    return nil;
}

@end
